package com.pactera.madp.cp.api.feign;

import com.pactera.madp.cp.api.model.WechatResponse;
import com.pactera.madp.cp.api.model.authorization.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * 微信三方平台接口
 * 详见 https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Before_Develop/Authorization_Process_Technical_Description.html
 *
 * @author hanyufei
 * @date 2021-05-19 10:51
 *
 */
@FeignClient(name="WxComponent",url="https://api.weixin.qq.com" ,qualifier = "WxComponent",path="/cgi-bin")
public interface WxComponentFeign {

    /**
     * 启动ticket推送服务
     *
     * @param apiStartPushTicketRequest apiStartPushTicketRequest
     * @return WechatResponse
     */

    @RequestMapping(value = "/component/api_start_push_ticket", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
     WechatResponse startPushTicket(@RequestBody ApiStartPushTicketRequest apiStartPushTicketRequest);

    /**
     * 获取令牌（component_access_token）
     *
     * @param componentAccessTokenRequest 第三方平台
     * @return json { "component_access_token": "xxx","expires_in": 7200 }
     */
    @ResponseBody
    @RequestMapping(value = "/component/api_component_token", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
     ComponentAccessTokenResponse getApiComponentToken(@RequestBody ComponentAccessTokenRequest componentAccessTokenRequest);
}